Socket Object Methods

Socket objects have the following methods. Except for makefile() these correspond to system calls applicable to sockets.
\begin{funcdesc}{accept}{}
Accept a connection.
The socket must be bound to an a...
...e address bound
to the socket on the other end of the connection.
\end{funcdesc}

\begin{funcdesc}{bind}{address}
Bind the socket to \var{address}. The socket mus...
...mat of \var{address} depends on the address family -- see above.)
\end{funcdesc}

\begin{funcdesc}{close}{}
Close the socket. All future operations on the socket ...
...Sockets are automatically closed when they are garbage-collected.
\end{funcdesc}

\begin{funcdesc}{connect}{address}
Connect to a remote socket at \var{address}.
...
...mat of \var{address} depends on the address family -- see above.)
\end{funcdesc}

\begin{funcdesc}{fileno}{}
Return the socket's file descriptor (a small integer). This is useful
with \code{select}.
\end{funcdesc}

\begin{funcdesc}{getpeername}{}
Return the remote address to which the socket is...
...ly --
see above.) On some systems this function is not supported.
\end{funcdesc}

\begin{funcdesc}{getsockname}{}
Return the socket's own address. This is useful ...
...the address returned depends on the address family --
see above.)
\end{funcdesc}

\begin{funcdesc}{getsockopt}{level\, optname\, buflen}
Return the value of the g...
...ode{struct} for a way to decode C structures
encoded as strings).
\end{funcdesc}

\begin{funcdesc}{listen}{backlog}
Listen for connections made to the socket.
The...
... and
should be at least 1; the maximum value is system-dependent.
\end{funcdesc}

\begin{funcdesc}{makefile}{mode}
Return a \dfn{file object} associated with the ...
...d socket object may be closed or
garbage-collected independently.
\end{funcdesc}

\begin{funcdesc}{recv}{bufsize\, flags}
Receive data from the socket. The return...
...eaning of the optional argument \var{flags}; it defaults to
zero.
\end{funcdesc}

\begin{funcdesc}{recvfrom}{bufsize}
Receive data from the socket. The return val...
...mat of \var{address} depends on the address family -- see above.)
\end{funcdesc}

\begin{funcdesc}{send}{string}
Send data to the socket. The socket must be connected to a remote
socket. Return the number of bytes sent.
\end{funcdesc}

\begin{funcdesc}{sendto}{string\, address}
Send data to the socket. The socket s...
...mat of \var{address} depends on the address family -- see above.)
\end{funcdesc}

\begin{funcdesc}{setblocking}{flag}
Set blocking or non-blocking mode of the soc...
...raised; in blocking mode, the calls block until they can proceed.
\end{funcdesc}

\begin{funcdesc}{setsockopt}{level\, optname\, value}
Set the value of the given...
...odule
\code{struct} for a way to encode C structures as strings).
\end{funcdesc}

\begin{funcdesc}{shutdown}{how}
Shut down one or both halves of the connection. ...
...\var{how} is \code{2}, further sends and receives are
disallowed.
\end{funcdesc}
Note that there are no methods read() or write(); use recv() and send() without flags argument instead.